package me.lc.hammerheads.layer;

import me.lc.hammerheads.core.GameSystem;
import me.lc.hammerheads.entity.BGType;

import com.wiyun.engine.nodes.Layer;
import com.wiyun.engine.nodes.Sprite;
import com.wiyun.engine.opengl.Texture2D;
import com.wiyun.engine.types.WYPoint;

public class GameBgLayer extends Layer {
	Sprite bg;

	public GameBgLayer() {
		Texture2D tex = GameSystem.tex_background_spring;
		bg = Sprite.make(tex);
		bg.setAnchorPercent(0, 0);
		bg.setPosition(WYPoint.make(0, 0));
		bg.setScaleX(GameSystem.Screen_Width / tex.getWidth());
		bg.setScaleY(GameSystem.Screen_Height / tex.getHeight());
		addChild(bg);
	}

	/**
	 * 更换背景
	 * 
	 * @param bgType
	 */
	public void changeBg(BGType bgType) {
		switch (bgType) {
		case spring:
			bg.setTexture(GameSystem.tex_background_spring);
			break;
		case summer:
			bg.setTexture(GameSystem.tex_background_summer);
			break;
		case autumn:
			bg.setTexture(GameSystem.tex_background_autumn);
			break;
		case winter:
			bg.setTexture(GameSystem.tex_background_winter);
			break;
		case desert:
			bg.setTexture(GameSystem.tex_background_desert);
			break;
		case livingroom:
			bg.setTexture(GameSystem.tex_background_livingroom);
			break;
		case tarmac:
			bg.setTexture(GameSystem.tex_background_tarmac);
			break;

		}
	}
}
